﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAL;
using System.Data;
using System.Data.SqlClient;
using Table_Dal;
namespace BLL
{
    public class MonHocBLL
    {
        DataAccessLayer dal = new DataAccessLayer();

        public List<MonHocTbl> LayTatCaMonHoc()
        {
            List<MonHocTbl> MonHocMoi = new List<MonHocTbl>();
            MonHocDAL mh = new MonHocDAL();
            MonHocMoi = mh.LayTatCaMonHoc();
            return MonHocMoi;
        }
        
        public bool SuaMonHoc(MonHocTbl monhoc)
        {
            MonHocDAL mh = new MonHocDAL();
            return mh.SuaMonHoc(monhoc);
        }
        public bool ThemMonHoc(string TenMon)
        {
            BusinessLogicLayer bll = new BusinessLogicLayer();
            MonHocDAL dal = new MonHocDAL();
            string ma = bll.RandomMa();
            while (dal.KiemTra_TrungKhoa(ma))
            {
                 ma = bll.RandomMa();
            }
            MonHocTbl monhoc = new MonHocTbl();
            monhoc.MaMonHoc = ma;
            monhoc.TenMonHoc = TenMon;
            
            return dal.ThemMonHoc(monhoc);
        }
        public bool XoaMonHoc(string mamon)
        {
            MonHocDAL mhdal = new MonHocDAL();
            mhdal.XoaMonHoc(mamon);
            return true; 
        }
        public List<MonHocTbl> LayMonHoc_MaDethi(string mssv)
        {
            MonHocDAL mhdal = new MonHocDAL();
            return mhdal.LayMonHoc_MaDethi(mssv);

        }

        public MonHocTbl LayMonHoc_TheoMaDethi(string made)
        {
            MonHocDAL mh = new MonHocDAL();
            return mh.LayMonHoc_TheoMaDethi(made);
        }
    }   
}

